/**
 * Created with IntelliJ IDEA.
 * Description: 最长二进制
 * User: 86187
 * Date: 2022-10-20
 * Time: 22:42
 */
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);

        int count = 0, result = 0;
        int n = in.nextInt();
        int length = Integer.SIZE;
        for(int i = 0; i < length; ++i) {
            if(((n >> i) & 1) != 0) {
                count++;
            } else {
                if(count > result)
                    result = count;
                count = 0;
            }
        }
        System.out.println(result);
    }

    /**
     *  题解
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int n = sc.nextInt();
            int modCount = 0;
            int count = 0;
            while (n != 0) {
                if ((n & 1) == 1) {
                    count++;
                    modCount = Math.max(modCount, count);
                } else {
                    count = 0;
                }
                n >>= 1;
            }
            System.out.println(modCount);

        }
    }
}